package com.qire.manhua.dal.converter;

import android.util.Size;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.util.List;

import androidx.room.TypeConverter;

/**
 * 本地章节持久化数据库字段转换器
 */
public class ChapterContentConverter {

    @TypeConverter
    public static String contentToString(List<String> list) {
        return new Gson().toJson(list);
    }

    @TypeConverter
    public static List<String> stringToContent(String value) {
        return new Gson().fromJson(value, new TypeToken<List<String>>(){}.getType());
    }

    @TypeConverter
    public static String sizeToString(List<Size> list) {
        return new Gson().toJson(list);
    }

    @TypeConverter
    public static List<Size> stringToSize(String value) {
        return new Gson().fromJson(value, new TypeToken<List<Size>>(){}.getType());
    }

}
